Post not yet marked as solved
Click to stop watching this thread.
You have stopped watching this post. Click to start watching again.
contentPostList.repliesup-voted.tooltip
Replied In
UID NFC tags
Bump because having the same issue -- trying to access the UID from NFCTag.miFare(tag) after creating an instance of NFCNDEFReaderSession or NFCTagReaderSession. Identifier value is always empty.FIgured it out:Inside your:func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {Add: if case let NFCTag.miFare(tag) = tags.first! {
session.connect(to: tags.first!) { (error: Error?) in
let tagUIDData = tag.identifier
var byteData: [UInt8] = []
tagUIDData.withUnsafeBytes { byteData.append(contentsOf: $0) }
var uidString = ""
for byte in byteData {
let decimalNumber = String(byte, radix: 16)
if (Int(decimalNumber) ?? 0) < 16 { // add leading zero
uidString.append("0\(decimalNumber)")
} else {
uidString.append(decimalNumber)
}
}
debugPrint("\(byteData) converted to Tag UID: \(uidString)")
}
}